#include <fstream>

#include "Manager.h"
#include "Scene.h"

Manager::Manager() {

}

Manager::~Manager() {
	for each(auto n in lstObject_) {
		delete n.second;
	}
	lstObject_.clear();
	
	for each(auto n in lstOrigin_) {
		delete n.second;
	}
	lstOrigin_.clear();
}

Node* Manager::getObject(string name) {
	for each(auto var in lstObject_) {
		if (var.second->getName() == name)
			return var.second;
	}
	return NULL;
}

Node* Manager::getObject(int id) {
	auto result = lstObject_.find(id);
	if (result == lstObject_.end())
		return NULL;
	return result->second;
}

Node* Manager::getOrigin(string name) {
	for each(auto var in lstOrigin_) {
		if (var.second->getName() == name)
			return var.second;
	}
	return NULL;
}
Node* Manager::getOrigin(int id) {
	auto result = lstOrigin_.find(id);
	if (result == lstOrigin_.end())
		return NULL;
	return result->second;
}

bool Manager::addObject(Node* node) {
	auto it = lstObject_.find(node->getId());
	if (it != lstObject_.end())
		return false;
	lstObject_[node->getId()] = node;
	return true;
}
bool Manager::addOrigin(Node* node) {
	auto it = lstOrigin_.find(node->getId());
	if (it != lstOrigin_.end())
		return false;
	lstOrigin_[node->getId()] = node;
	return true;
}
